home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.plaf.basic;
-
- import com.sun.java.swing.Action;
- import com.sun.java.swing.Icon;
- import com.sun.java.swing.JComponent;
- import com.sun.java.swing.JList;
- import com.sun.java.swing.JPanel;
- import com.sun.java.swing.UIManager;
- import com.sun.java.swing.event.ListSelectionListener;
- import com.sun.java.swing.plaf.FileChooserUI;
- import com.sun.java.swing.preview.JFileChooser;
- import com.sun.java.swing.preview.filechooser.FileFilter;
- import com.sun.java.swing.preview.filechooser.FileView;
- import java.awt.BorderLayout;
- import java.awt.event.MouseListener;
- import java.beans.PropertyChangeEvent;
- import java.beans.PropertyChangeListener;
- import java.io.File;
-
- public abstract class BasicFileChooserUI extends FileChooserUI implements PropertyChangeListener {
- protected Icon directoryIcon = null;
- protected Icon fileIcon = null;
- protected Icon computerIcon = null;
- protected Icon hardDriveIcon = null;
- protected Icon floppyDriveIcon = null;
- protected Icon newFolderIcon = null;
- protected Icon upFolderIcon = null;
- protected Icon homeFolderIcon = null;
- protected Icon listViewIcon = null;
- protected Icon detailsViewIcon = null;
- protected String saveButtonText = null;
- protected String openButtonText = null;
- protected String cancelButtonText = null;
- protected String updateButtonText = null;
- protected String helpButtonText = null;
- protected static String saveButtonToolTipText = null;
- protected static String openButtonToolTipText = null;
- protected static String cancelButtonToolTipText = null;
- protected static String updateButtonToolTipText = null;
- protected static String helpButtonToolTipText = null;
- private Action approveSelectionAction = new ApproveSelectionAction(this);
- private Action cancelSelectionAction = new CancelSelectionAction(this);
- private Action updateAction = new UpdateAction(this);
- private Action newFolderAction = new NewFolderAction(this);
- private Action goHomeAction = new GoHomeAction(this);
- private Action changeToParentDirectoryAction = new ChangeToParentDirectoryAction(this);
- private JFileChooser filechooser = null;
- private AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter(this);
- protected String fileDescription = "Generic File";
- protected String directoryDescription = "Directory";
- protected BasicDirectoryModel model = null;
- protected BasicFileView fileView = new BasicFileView(this);
- protected JPanel accessoryPanel = null;
-
- public BasicFileChooserUI(JFileChooser b) {
- }
-
- protected void addListeners() {
- this.getFileChooser().addPropertyChangeListener(this.model);
- this.getFileChooser().addPropertyChangeListener(this);
- }
-
- protected MouseListener createDoubleClickListener(JList list) {
- return new DoubleClickListener(this, list);
- }
-
- public ListSelectionListener createListSelectionListener() {
- return new SelectionListener(this);
- }
-
- protected void createModel() {
- this.model = new BasicDirectoryModel(this.getFileChooser());
- }
-
- public abstract void ensureFileIsVisible(File var1);
-
- public FileFilter getAcceptAllFileFilter() {
- return this.acceptAllFileFilter;
- }
-
- public JPanel getAccessoryPanel() {
- return this.accessoryPanel;
- }
-
- public String getApproveButtonText() {
- String buttonText = this.getFileChooser().getApproveButtonText();
- if (buttonText != null) {
- return buttonText;
- } else if (this.getFileChooser().getDialogType() == 0) {
- return this.openButtonText;
- } else {
- return this.getFileChooser().getDialogType() == 1 ? this.saveButtonText : null;
- }
- }
-
- public String getApproveButtonToolTipText() {
- String tooltipText = this.getFileChooser().getApproveButtonToolTipText();
- if (tooltipText != null) {
- return tooltipText;
- } else if (this.getFileChooser().getDialogType() == 0) {
- return openButtonToolTipText;
- } else {
- return this.getFileChooser().getDialogType() == 1 ? saveButtonToolTipText : null;
- }
- }
-
- public Action getApproveSelectionAction() {
- return this.approveSelectionAction;
- }
-
- public Action getCancelSelectionAction() {
- return this.cancelSelectionAction;
- }
-
- public Action getChangeToParentDirectoryAction() {
- return this.changeToParentDirectoryAction;
- }
-
- public String getDialogTitle() {
- return this.getApproveButtonText();
- }
-
- public abstract String getDirectoryName();
-
- public JFileChooser getFileChooser() {
- return this.filechooser;
- }
-
- public abstract String getFileName();
-
- public FileView getFileView() {
- return this.fileView;
- }
-
- public Action getGoHomeAction() {
- return this.goHomeAction;
- }
-
- public BasicDirectoryModel getModel() {
- return this.model;
- }
-
- public Action getNewFolderAction() {
- return this.newFolderAction;
- }
-
- public Action getUpdateAction() {
- return this.updateAction;
- }
-
- public abstract void installComponents();
-
- public void installUI(JComponent c) {
- this.accessoryPanel = new JPanel(new BorderLayout());
- this.filechooser = (JFileChooser)c;
- this.loadIcons();
- this.loadStrings();
- this.createModel();
- this.installComponents();
- this.addListeners();
- }
-
- protected void loadIcons() {
- this.directoryIcon = UIManager.getIcon("FileView.directoryIcon");
- this.fileIcon = UIManager.getIcon("FileView.fileIcon");
- this.computerIcon = UIManager.getIcon("FileView.computerIcon");
- this.hardDriveIcon = UIManager.getIcon("FileView.hardDriveIcon");
- this.floppyDriveIcon = UIManager.getIcon("FileView.floppyDriveIcon");
- this.newFolderIcon = UIManager.getIcon("FileChooser.newFolderIcon");
- this.upFolderIcon = UIManager.getIcon("FileChooser.upFolderIcon");
- this.homeFolderIcon = UIManager.getIcon("FileChooser.homeFolderIcon");
- this.detailsViewIcon = UIManager.getIcon("FileChooser.detailsViewIcon");
- this.listViewIcon = UIManager.getIcon("FileChooser.listViewIcon");
- }
-
- protected void loadStrings() {
- this.saveButtonText = UIManager.getString("FileChooser.saveButtonText");
- this.openButtonText = UIManager.getString("FileChooser.openButtonText");
- this.cancelButtonText = UIManager.getString("FileChooser.cancelButtonText");
- this.updateButtonText = UIManager.getString("FileChooser.updateButtonText");
- this.helpButtonText = UIManager.getString("FileChooser.helpButtonText");
- saveButtonToolTipText = UIManager.getString("FileChooser.saveButtonToolTipText");
- openButtonToolTipText = UIManager.getString("FileChooser.openButtonToolTipText");
- cancelButtonToolTipText = UIManager.getString("FileChooser.cancelButtonToolTipText");
- updateButtonToolTipText = UIManager.getString("FileChooser.updateButtonToolTipText");
- helpButtonToolTipText = UIManager.getString("FileChooser.helpButtonToolTipText");
- }
-
- public abstract void propertyChange(PropertyChangeEvent var1);
-
- public abstract void rescanCurrentDirectory();
-
- public abstract void setDirectoryName(String var1);
-
- public abstract void setFileName(String var1);
-
- protected void uninstallListeners() {
- if (this.getFileChooser() != null) {
- this.getFileChooser().removeAll();
- this.getFileChooser().removePropertyChangeListener(this);
- this.getFileChooser().removePropertyChangeListener(this.model);
- }
-
- }
-
- public void uninstallUI(JComponent c) {
- this.filechooser.removeAll();
- this.uninstallListeners();
- if (this.accessoryPanel != null) {
- this.accessoryPanel.removeAll();
- }
-
- this.filechooser = null;
- this.accessoryPanel = null;
- }
- }
-